<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Person {
            state = {
                a: 1,
                b: 2
            }
            a = 1;
            b = 2;
            constructor(name, age) {
                this.name = name
                this.age = age
            }
        }
        let obj = new Person("twj", 100)
        console.log(obj)

        //加#号代表私有属性或私有方法
        class Cache {
            static #count = 0
            static getCount() {
                return this.#count
            }
            #obj = {}
            get(key) {
                return this.#obj[key]
            }
            set(key, value) {
                this.#obj[key] = value
            }
            #prstore() {
            }
            has() { //判断#obj是不是当前类的属性
                return #obj in this
            }
        }
        let store = new Cache()
        store.set("name", "twj")
        store.set("age", 100)
        console.log(store)
        console.log(store.get("name")) //twj
        //console.log(store.#obj) //直接报错
        //console.log(Cache.#count) //直接报错
        console.log(Cache.getCount()) //0
        let s = new Cache()
        console.log(s.has()) //true

    </script>
</body>

</html>